<template>
  <div class="choose" @click="changeChooseShow(false)" v-if="goodsProduct">
    <van-popup v-model="show" position="bottom" :style="{ height: '70%' }">
      <div class="goods">
        <div class="msg">
          <div class="left">
            <img :src="goodsProduct.shareImage" alt="" />
            <div class="type">
              <p>￥{{ goodsProduct.defaultProduct.productPrice }}</p>
              <p>已选规格：默认</p>
            </div>
          </div>
          <div class="right">
            <img
              @click="changeChooseShow(false)"
              src="	https://image-mall.gxptkc.com/m/resources/goods_detail/close.png"
              alt=""
            />
          </div>
        </div>
        <div class="number" @click.stop="">
          <p>购买数量</p>
          <div class="counter">
            <span @click="count--">-</span>
            <input type="text" v-model="count" />
            <span @click="count++">+</span>
          </div>
        </div>
      </div>
      <div class="action">
        <button>加入购物车</button>
        <button>立即购买</button>
      </div>
    </van-popup>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  props: ["goodsProduct"],
  data() {
    return {
      show: false,
      count: 1,
    };
  },
  computed: {
    ...mapState(["chooseShow"]),
  },
  methods: {
    ...mapMutations(["changeChooseShow"]),
  },
  watch: {
    chooseShow(newVal) {
      this.show = newVal;
    },
  },
};
</script>
<style lang="scss" scoped>
.choose {
  .goods {
    padding: 10rem;
    .msg {
      display: flex;
      justify-content: space-between;
      .left {
        display: flex;
        align-items: center;
        img {
          width: 75rem;
          height: 75rem;
          margin-right: 15rem;
        }
        .type {
          p {
            font-size: 25rem;
            color: #fc1c1c;
            &:last-child {
              font-size: 14rem;
              color: #343434;
              margin-top: 6rem;
            }
          }
        }
      }
      .right {
        width: 23rem;
        height: 23rem;
      }
    }
    .number {
      font-size: 14rem;
      color: #666;
      display: flex;
      justify-content: space-between;
      margin-top: 10rem;
      p {
      }
      .counter {
        height: 25rem;
        display: flex;
        color: #999;
        font-weight: bold;
        span {
          padding: 3rem 3rem;
          border: 1rem solid rgb(245, 245, 245);
          display: flex;
          align-items: center;
          justify-content: center;
          width: 25rem;
        }
        input {
          width: 39rem;
          padding: 0;
          text-align: center;
          border: 1rem solid rgb(245, 245, 245);
        }
      }
    }
  }
  .action {
    height: 50rem;
    width: 100%;
    display: flex;
    justify-content: center;
    border-top: 1px solid rgb(245, 245, 245);
    align-items: center;
    position: fixed;
    bottom: 0;
    button {
      height: 35rem;
      width: 45%;
      border: none;
      font-size: 15rem;
      color: #fff;
      background: #ff821c;
      border-radius: 17rem 0 0 17rem;
      &:last-child {
        background: #f30300;
        border-radius: 0 17rem 17rem 0;
      }
    }
  }
}
</style>